﻿var hg_time = null;
var lgjz = "";
var ltplj = "";
var yqd = 0;
function kaishihuoqu(a){
    var wbsrwz = document.getElementById("wbsrwz");
    wbsrwz.value = ylwz;
    
	a.style.backgroundImage = "url(images/bwl_yonghu.png)";
    kaishihuoqu2();
}
function preLoadImg(url) {
    var img = new Image();
    img.src = url;
} 
function kaishihuoqu2() {
	yqd = 1;
	var huidiao = document.getElementById("huidiao");
	var huidiao2 = document.getElementById("huidiao2");
	var xhr = new XMLHttpRequest();
	xhr.open("GET", "sz/hd.php?&r=" + Math.random().toString(), true);
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.onreadystatechange = function() {
		var XMLHttpReq = xhr;
		if (XMLHttpReq.readyState == 4) {
			if (XMLHttpReq.status == 200) {
				var text = XMLHttpReq.responseText;
				strs = text.split("|Anters_fg|");
				if (strs.length >= 1) {
					var gjzzs = strs[0];
					if (lgjz != strs[0]) {
						huidiao.innerHTML = gjzzs;
						lgjz = strs[0];
                        document.getElementById("bt_xd").style.backgroundImage = "url(images/bwl_n_xd.png)";
					}
					if (strs.length >= 2 && strs[1] != ltplj) {
					   var lsHTML;
					   if(strs.length >= 2){
					       //lsHTML  = "<div class='imgbox'><a href='"+strs[1]+"'><img src='" + strs[1] + "'></img></a></div>";
                           //var lssrc = "sz/" + sjh + "/TP." + strs[2] + "?r="+Math.random().toString();
					       lsHTML  = "<div class='imgbox'><a target='_blank' href='images?url=" + strs[1] + "'><img src='images?url=" + strs[1] + "'></img></a></div>";
                           preLoadImg("'images?url=" + strs[1]);
					       
					   }
						huidiao2.innerHTML = lsHTML;
						ltplj = strs[1];
                        document.getElementById("bt_ty").style.backgroundImage = "url(images/bwl_n_ty.png)";
					}
				}
				if (hg_time) clearTimeout(hg_time);
				hg_time = setTimeout("kaishihuoqu2();", 3500);
			}
		}
	};
	xhr.send();
	hg_time = setTimeout("kaishihuoqu2();", 6000);
}
var goToWhere = function(where) {
	var me = this;
	me.site = [];
	me.sleep = me.sleep ? me.sleep : 16;
	me.fx = me.fx ? me.fx : 6;
	clearInterval(me.interval);
	var dh = document.documentElement.scrollHeight || document.body.scrollHeight;
	var height = !! where ? dh : 0;
	me.interval = setInterval(function() {
		var top = document.documentElement.scrollTop || document.body.scrollTop;
		var speed = (height - top) / me.fx;
		if (speed === me.site[0]) {
			window.scrollTo(0, height);
			clearInterval(me.interval);
		}
		window.scrollBy(0, speed);
		me.site.unshift(speed);
	}, me.sleep);
};
var yixianshi = 0;
var diag;

function xianshiT(a) {
    a.style.backgroundImage = "url(images/bwl_ty.png)";
    
    if(yqd != 1)return;
	if (yixianshi == 0) {
		yixianshi = 1;
		diag = new Dialog();
		diag.Width = 310;
		diag.Height = 400;
		diag.bottom = 0;
		diag.Title = "图片";
		diag.InvokeElementId = "huidiao_d";
        diag.CancelEvent=function(){yixianshi = 0;diag.close();};
		diag.Modal = false;
		diag.show();
	} else {
		yixianshi = 0;
		diag.close();
	}
}
function focuswbsrwz(){
    var wbsrwz = document.getElementById("wbsrwz");
    wbsrwz.value = ylwz;
    wbsrwz.focus();
    
}
function qkbwl(){
    var wbsrwz = document.getElementById("wbsrwz");
    var yonghutubiao = document.getElementById("yonghutubiao");
    wbsrwz.value = ylwz;
    if (hg_time) clearTimeout(hg_time);
    yonghutubiao.style.backgroundImage = "url(images/ball.png)";
    if(yixianshi == 1){
		yixianshi = 0;
		diag.close();
    }
    var huidiao = document.getElementById("huidiao");
    huidiao.innerHTML = "";
    yqd = 0;
    hg_time = null;
    lgjz = "";
    ltplj = "";
    goToWhere(0);
    
    
}
function msfh(){
    setTimeout("goToWhere(0)",2000);
}
function daodibu(a){
    a.style.backgroundImage = "url(images/bwl_xd.png)";
    $('html, body').animate({
        scrollTop: $("#huidiao").offset().top
        }, 300);
}